﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;


public partial class AdminLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = new HttpCookie("MyCookie");        
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {

        Session["Username"] = login.Text;
        DataSet ds = new DataSet();
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
        con.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "ADM_sCheckLogin";

        cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar)).Value = login.Text;
        cmd.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar)).Value = password.Text;
        cmd.Parameters.Add(new SqlParameter("@Role", SqlDbType.Int)).Value = radiolist1.SelectedValue.ToString();
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        sda.Fill(ds);
        con.Close();

        if (ds.Tables[0].Rows[0]["status"].ToString() == "1")
        {
            Session["Authentication"] = "Yes";
            if(radiolist1.SelectedValue.ToString()=="1")
            {
                //Response.Redirect("~/NewDashboard.aspx?Person=" + login.Text);
                //Session["Person"] = login.Value;
               
                Response.Redirect("~/NewDashboard.aspx");
                
                    
            }
            else{
                //Response.Redirect("~/SalesUserDashboards.aspx?Person=" + login.Text);
                //Session["Person"] = login.Value;
                Response.Redirect("~/SalesUserDashboards.aspx");
                

            }
        }

    }
}